package com.th.supcom.pds.drugreturn.client.widget;

import java.util.List;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.th.supcom.pds.auditprescription.client.common.RefuseModelMockFactory;
import com.th.supcom.pds.auditprescription.client.model.RefuseReasonModel;

/**
 * 拒绝退药时弹出框
 * 
 * @author yzhang
 */
public class DrugReturnRefuseWindow extends Dialog
{
    /** 拒绝窗口模板下拉框 */
    private ComboBox <RefuseReasonModel> m_comboBox;
    /** 模拟的拒绝理由模板 */
    private List <RefuseReasonModel> m_lists;
    /** 拒绝窗口备注 */
    private TextArea m_textArea;

    public DrugReturnRefuseWindow ()
    {
        initUI ();
    }

    public void clearDate ()
    {
        m_textArea.clear ();
        m_comboBox.select (0);
    }

    public ComboBox <RefuseReasonModel> getComboBox ()
    {
        return m_comboBox;
    }

    public List <RefuseReasonModel> getLists ()
    {
        return m_lists;
    }

    public TextArea getTextArea ()
    {
        return m_textArea;
    }

    /**
     * 初始化面板
     */
    private void initUI ()
    {
        final FormData formData = new FormData ("90%");
        setSize (300, 200);
        setOnEsc (false);
        setHeading ("拒绝理由");
        setModal (true);
        setButtons (Dialog.YESNO);
        setButtonAlign (HorizontalAlignment.CENTER);

        final FormPanel panel = new FormPanel ();
        panel.setSize (300, 200);
        panel.setHeaderVisible (false);
        /** 拒绝理由 */
        ListStore <RefuseReasonModel> store;
        store = new ListStore <RefuseReasonModel> ();
        m_lists = RefuseModelMockFactory.getRefuseModel ();
        store.add (m_lists);
        m_comboBox = new ComboBox <RefuseReasonModel> ();
        m_comboBox.setEditable (false);
        m_comboBox.setFieldLabel ("模板");
        m_comboBox.setDisplayField ("name");
        m_comboBox.setTriggerAction (TriggerAction.ALL);
        m_comboBox.setValue (m_lists.get (0));
        m_comboBox.setStore (store);

        m_textArea = new TextArea ();
        m_textArea.setFieldLabel ("备注");
        m_textArea.setHeight (85);

        panel.add (m_comboBox, formData);
        panel.add (m_textArea, formData);

        add (panel);
    }

    public void setComboBox (final ComboBox <RefuseReasonModel> comboBox)
    {
        m_comboBox = comboBox;
    }

    public void setLists (final List <RefuseReasonModel> lists)
    {
        m_lists = lists;
    }

    public void setTextArea (final TextArea textArea)
    {
        m_textArea = textArea;
    }

}
